package com.zzyl.nursing.controller.member;

import com.zzyl.common.core.controller.BaseController;
import com.zzyl.common.core.domain.AjaxResult;
import com.zzyl.nursing.dto.BindingFamilyMemberDto;
import com.zzyl.nursing.dto.UserLoginRequestDto;
import com.zzyl.nursing.dto.member.HealthIndexDataDto;
import com.zzyl.nursing.service.IFamilyMemberElderService;
import com.zzyl.nursing.service.IFamilyMemberService;
import com.zzyl.nursing.vo.LoginVo;
import com.zzyl.nursing.vo.member.FamilyMemberElderListVo;
import com.zzyl.nursing.vo.member.FamilyMemberElderVo;
import com.zzyl.nursing.vo.member.HealthDataVo;
import com.zzyl.nursing.vo.member.HealthIndexDataVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 老人家属Controller
 * 
 * @author ruoyi
 * @date 2025-04-26
 */
@RestController
@RequestMapping("/member/user")
@Api(tags = "老人家属的接口")
public class FamilyMemberController extends BaseController
{
    @Autowired
    private IFamilyMemberService familyMemberService;


    @PostMapping("/login")
    public AjaxResult login(@RequestBody UserLoginRequestDto dto){
        LoginVo vo = familyMemberService.login(dto);
        return success(vo);
    }

    /**
     * 绑定老人家属
     * @param dto
     * @return
     */
    @PostMapping("/add")
    public AjaxResult bindingFamilyMember(@RequestBody BindingFamilyMemberDto dto){
        familyMemberService.bindingFamilyMember(dto);
        return success();
    }
    /**
     * 查询家人列表
     */
    @GetMapping("/my")
    public AjaxResult getFamilyMemberList(){
        List<FamilyMemberElderVo> list  = familyMemberService.getFamilyMemberList();
        return success(list);
    }

    /**
     * 查看家人列表（分页查询）
     * @return 家人列表（分页查询）
     */
    @GetMapping("/list-by-page")
    public AjaxResult getFamilyMemberListByPage(){
        startPage();
        List<FamilyMemberElderListVo> list = familyMemberService.getFamilyMemberListByPage();
        return success(list);
    }

    /**
     * 查询健康数据
     * @param iotId
     * @return 健康数据
     */
    @GetMapping("/queryServiceProperties/{iotId}")
    public AjaxResult queryServiceProperties(@PathVariable("iotId") String iotId){
        List<HealthDataVo> healthDataVos = familyMemberService.queryServiceProperties(iotId);
        return success(healthDataVos);
    }

    /**
     * 按天统计查询指标数据
     * @param dto
     * @return
     */
    @GetMapping("/queryDeviceDataListByDay")
    public AjaxResult queryDeviceDataListByDay(HealthIndexDataDto dto){
        List<HealthIndexDataVo> healthDataVos = familyMemberService.queryDeviceDataListByDay(dto);
        return success(healthDataVos);
    }

    @GetMapping("/queryDeviceDataListByWeek")
    public AjaxResult queryDeviceDataListByWeek(HealthIndexDataDto dto){
        List<HealthIndexDataVo> healthDataVos = familyMemberService.queryDeviceDataListByWeek(dto);
        return success(healthDataVos);
    }
}
